<template>
  <div>
    <van-address-edit
      :area-list="areaList"
      show-delete
      show-set-default
      show-search-result
      :search-result="searchResult"
      :area-columns-placeholder="['请选择', '请选择', '请选择']"
      @save="onSave"
      @delete="onDelete"
    />
  </div>
</template>

<script>
import { Toast } from "vant";
import { areaList } from "@vant/area-data";
import { mapActions, mapGetters } from "vuex";
export default {
  props: ["info"],
  data() {
    return {
      areaList,
      searchResult: []
    };
  },
  methods: {
    ...mapActions({
      changedata: "address/dataActions",
      addaddress: "address/addressaddActions"
    }),
    onSave(e) {
      // console.log(e);
      Toast("save");
      let data = {
        uid: JSON.parse(sessionStorage.getItem("user")).uid,
        username: e.name,
        userphone: e.tel,
        useraddress: e.province + e.city + e.county + e.addressDetail
      };
      this.changedata(data);

      let address = {
          uid: JSON.parse(sessionStorage.getItem('user')).uid,
          username: e.name,
          userphone: e.tel,
          location:e.province+e.city+e.county,
          useraddress:e.addressDetail,
      };
      this.addaddress(address);
      this.$router.go(-1);
      // console.log(this.data);
      // this.info.isshow=false
    },
    onDelete() {
      Toast("delete");
    }
  },
  computed: {
    ...mapGetters({
      data: "address/data"
    })
  },
  mounted() {}
};
</script>

<style>
</style>